#include<stdio.h>
#include<string.h>
#include<math.h>

int n;
int weight[110];
int put[110][50000];
int total;
int best;

int main()
{
	int i,j,k;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&weight[i]);
		total+=weight[i];	
	}

	put[0][0]=1;
	for (i=0;i<n;i++) // try every people
	{  
		for (j=n/2;j>=0;j--)
		{
			for (k=45000;k>=0;k--) //The total weight will always less than 45000
			{
				if (put[j][k]!=0)
					put[j+1][ k+weight[i] ]=1;
			}
		}
	}

	for (i=0;i<=45000;i++) 
	{
		if(put[n/2][i]==0) 
			continue;
		if(abs(total-2*i)<abs(total-2*best)) 
			best = i;
	}

	if(best>total-best) 
		best=total-best;
 	printf("%d %d\n",best,total-best);


	return 0;
}
 